import axios from "axios";


export const login = ({ commit }, payload) => {
  return new Promise((resolve, reject) => {
    axios
      .post("/api/token", payload)
      .then(response => {
        const auth = response.data;
        commit("setLogin", auth);
        resolve(response);
      })
      .catch(error => {
    
        reject(error.response);
      });
  });
};
export const register = ({ commit }, payload) => {
  return new Promise((resolve, reject) => {
     axios
      .post("/api/account/register", payload)
      .then(response => {
     
        resolve(response);
      })
      .catch(error => {
        reject(error.response);
      });
  });
};


export const logout = ({ commit }) => {
  commit("setLogout");
};
